<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<!--
将value为“yellow”的复选框，将value值改为：green
-->


<br>
<br>

数量 : <input type="text" id="text1" onmouseout="xiaoJi()">
<br>
单价 : <input type="text" id="text2" onmouseout="xiaoJi()">
<br>
小计 : <input type="text" id="text3" value="0">
<br>
选购项目 : <input type="radio" name="radio" value="500" checked="checked">500
<input type="radio" name="radio" value="1000">1000
<br>

<input type="button" onclick="count()" value="开始计算">

总价 : <input type="text" id="text4" value="0">


</body>

<script>
    var text1 = document.getElementById("text1");
    var text2 = document.getElementById("text2");
    var text3 = document.getElementById("text3");
    var text4 = document.getElementById("text4");

    var radio = document.getElementsByName("radio");

    function xiaoJi() {
        text3.value = parseInt(text1.value) + parseInt(text2.value);
    }

    function count() {
        for (var i = 0; i < radio.length; i++) {
            alert(radio[i].checked)
            if (radio[i].checked) {
                text4.value = parseInt(text3.value) + parseInt(radio[i].value);
                return
            }
        }
    }

</script>
</html>